home *** CD-ROM | disk | FTP | other *** search
- #include "SAT.h"
-
- Handle theSound;
- FacePtr faces[6];
-
- /* Prototypes */
- void InitMySprite();
- pascal void SetupMySprite (SpritePtr);
- pascal void HandleMySprite (SpritePtr);
-
-
- void InitMySprite()
- {
- int i;
-
- theSound = SATGetSound(128); /*Preload the sound */
- for (i=0; i<=5; i++)
- faces[i] = GetFace(128+i); /* Preload all sprite faces */
- }
-
- /* Important! Callback routines (Setup, Handle, Hit) must be declared "pascal"! */
-
- pascal void SetupMySprite (me)
- SpritePtr me;
- {
- me->mode = 0; /* Pick a valid face number */
- me->speed.h = 2; /* Set the speed - only horizontal is used here */
- me->task = HandleMySprite; /* Set a handling routine. MANDATORY! If nil, the sprite will self-destruct. */
- }
-
- pascal void HandleMySprite (me)
- SpritePtr me;
- {
- /* Choose face */
- me->mode = (me->mode + 1) % 6;
- me->face = faces[me->mode];
-
- /* Move */
- me->position.h = me->position.h + me->speed.h;
- if (me->position.h > gSAT.offSizeH - 16)
- {
- me->speed.h = -2;
- SATSoundPlay(theSound, 1, false);
- };
- if (me->position.h < -16)
- {
- me->speed.h = 2;
- SATSoundPlay(theSound, 1, false);
- };
- }
-